Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
@turf/clean-coords
Advanced tools
@turf/clean-coords is a module from the Turf.js library that is used to clean coordinates in GeoJSON data. It removes redundant coordinates, such as consecutive duplicate points, and ensures the data is optimized for further processing or visualization.
Remove Redundant Coordinates
This feature removes consecutive duplicate coordinates from a GeoJSON LineString. The input line has redundant points which are removed in the cleaned output.
const turf = require('@turf/turf');
const line = turf.lineString([
[0, 0], [1, 1], [1, 1], [2, 2], [3, 3], [3, 3], [4, 4]
]);
const cleaned = turf.cleanCoords(line);
console.log(cleaned);
Clean Polygon Coordinates
This feature cleans redundant coordinates from a GeoJSON Polygon. The input polygon has duplicate points which are removed in the cleaned output.
const turf = require('@turf/turf');
const polygon = turf.polygon([
[
[0, 0], [1, 1], [1, 1], [1, 0], [0, 0], [0, 0]
]
]);
const cleaned = turf.cleanCoords(polygon);
console.log(cleaned);
The simplify-geojson package is used to simplify GeoJSON data by reducing the number of points in geometries while preserving the overall shape. Unlike @turf/clean-coords, which focuses on removing redundant points, simplify-geojson reduces the complexity of the geometry.
The geojson-rewind package ensures that GeoJSON polygons have the correct winding order. While @turf/clean-coords removes redundant coordinates, geojson-rewind focuses on correcting the order of coordinates to ensure they follow the right-hand rule.
Removes redundant coordinates from any GeoJSON Geometry.
Parameters
geojson
(Geometry | Feature) Feature or Geometryoptions
Object Optional parameters (optional, default {}
)
options.mutate
boolean allows GeoJSON input to be mutated (optional, default false
)Examples
var line = turf.lineString([[0, 0], [0, 2], [0, 5], [0, 8], [0, 8], [0, 10]]);
var multiPoint = turf.multiPoint([[0, 0], [0, 0], [2, 2]]);
turf.cleanCoords(line).geometry.coordinates;
//= [[0, 0], [0, 10]]
turf.cleanCoords(multiPoint).geometry.coordinates;
//= [[0, 0], [2, 2]]
Returns (Geometry | Feature) the cleaned input Feature/Geometry
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/clean-coords
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
6.5.0
@turf/points-with-polygon
Add MultiPoint support
(PR https://github.com/Turfjs/turf/pull/2137 - Author @twelch)@turf/dissolve
Complete rewrite of the dissolve module to resolve many bugs
(PR https://github.com/Turfjs/turf/pull/2110 - Author @rowanwins)
@turf/mask
Complete rewrite of the mask module to resolve many bugs
(PR https://github.com/Turfjs/turf/pull/2130 - Author @rowanwins)
@turf/boolean-valid
Add missing dependency to
(PR https://github.com/Turfjs/turf/pull/2094 - Author @rycgar)
@turf/boolean-overlap
Improve clarity
(PR https://github.com/Turfjs/turf/pull/2133 - Author @patrickbrett)FAQs
turf clean-coords module
The npm package @turf/clean-coords receives a total of 456,644 weekly downloads. As such, @turf/clean-coords popularity was classified as popular.
We found that @turf/clean-coords demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.